<?php

namespace App\Http\Controllers\user;

use App\Dao\RechargeDao;
use App\Dao\UsersDao;
use App\Exceptions\SysExceptions;
use App\Services\Code;
use EasyWeChat\Kernel\Exceptions\HttpException;
use EasyWeChat\Kernel\Exceptions\InvalidArgumentException;
use EasyWeChat\Kernel\Exceptions\InvalidConfigException;
use EasyWeChat\Kernel\Exceptions\RuntimeException;

class UsersController extends BaseController
{
    /**
     * @return array
     * @throws SysExceptions
     * @throws HttpException
     * @throws InvalidArgumentException
     * @throws InvalidConfigException
     * @throws RuntimeException
     * @throws \Psr\SimpleCache\InvalidArgumentException
     */
    public function register(): array
    {
        $params = request()->all();
        return Code::message('',200,UsersDao::register($params));
    }

    public function user_login_lists(): array
    {
        $params = request()->all();
        return Code::message('',200,UsersDao::u_l_users($params));
    }


    /**
     * @throws SysExceptions
     */
    public function login_u(): array
    {
        $params = request()->all();
        return Code::message('',200,UsersDao::login_u($params));
    }


    public function do_login(): array
    {
        $params = request()->all();
        return Code::message('',200,UsersDao::do_login($params));
    }


    public function user_info(): array
    {
        $params = array_merge([
            'user_id'=>getUserToken()
        ],request()->all());
        return Code::message('',200,UsersDao::user_info($params));
    }

    public function set_id_card(): array
    {
        $params = array_merge([
            'user_id'=>getUserToken()
        ],request()->all());
        return Code::message('',200,UsersDao::set_id_card($params));
    }

    public function update_pay_pass(): array
    {
        $params = array_merge([
            'user_id'=>getUserToken()
        ],request()->all());
        return Code::message('',200,UsersDao::update_pay_pass($params));
    }

    public function widthwal(): array
    {
        $params = array_merge([
            'user_id'=>getUserToken()
        ],request()->all());
        UsersDao::widthwal($params);
        return Code::message('',200);
    }


    public function users_count_data(): array
    {
        $params = array_merge([
            'user_id'=>getUserToken()
        ],request()->all());
        return Code::message('',200,UsersDao::users_count_data($params));
    }

    public function widthwal_lists(): array
    {
        $params = array_merge([
            'user_id'=>getUserToken()
        ],request()->all());
        return Code::message('',200,UsersDao::widthwal_lists($params));
    }

    public function bills()
    {
        $params = array_merge([
            'user_id'=>getUserToken()
        ],request()->all());
        return Code::message('',200,UsersDao::bills($params));
    }

    public function bills_score(): array
    {
        $params = array_merge([
            'user_id'=>getUserToken()
        ],request()->all());
        return Code::message('',200,UsersDao::bills_score($params));
    }


    public function setCardJson(): array
    {
        $params = request()->all();
        $params['user_id'] = getUserToken();
        UsersDao::setCardJson($params);
        return Code::message('设置成功');
    }


    /**
     * @throws SysExceptions
     */
    public function score_to_balance(): array
    {
        $params = array_merge(request()->all(),[
            'user_id'=>getUserToken()
        ]);
        UsersDao::score_to_balance($params);
        return Code::message('',200);
    }


    public function score_to_balance_to_user(): array
    {
        $params = array_merge(request()->all(),[
            'user_id'=>getUserToken()
        ]);
        UsersDao::score_to_balance_to_user($params);
        return Code::message('',200);
    }



    public function balance_to_user(): array
    {
        $params = array_merge(request()->all(),[
            'user_id'=>getUserToken()
        ]);
        UsersDao::balance_to_user($params);
        return Code::message('',200);
    }

    /**
     * @throws SysExceptions
     */
    public function forget_pay_pass(): array
    {
        $params = array_merge(request()->all(),[
            'user_id'=>getUserToken()
        ]);
        UsersDao::forget_pay_pass($params);
        return Code::message('',200);
    }

    public function update_user_info()
    {
        $params = array_merge([
            'user_id'=>getUserToken()
        ],request()->all());
        UsersDao::update_user_info($params);
        return Code::message('',200);
    }



    public function get_tuan_users(): array
    {
        $params = request()->all();
        return Code::message('',200,UsersDao::get_tuan_users($params));
    }


    /**
     * @throws SysExceptions
     */
    public function recharge(): array
    {
        $params = array_merge([
            'user_id'=>getUserToken()
        ],request()->all());
        return Code::message('',200,RechargeDao::rechargeUsers($params));
    }
    public function rLists(): array
    {
        $params = array_merge([
            'user_id'=>getUserToken()
        ],request()->all());
        return Code::message('',200,RechargeDao::rechargeLists($params));
    }

    public function share_code(){
        $params = array_merge([
            'user_id'=>getUserToken()
        ],request()->all());
        UsersDao::share_code($params);
        return Code::message('',200);
    }


    public function update_user_info_wx()
    {
        $params = array_merge([
            'user_id'=>getUserToken()
        ],request()->all());
        UsersDao::update_user_info_wx($params);
        return Code::message('',200);
    }

    /**
     * @return array
     */
    public function get_recom_user(){
        $params = array_merge([
            'user_id'=>getUserToken()
        ],request()->all());
        return Code::message('',200,UsersDao::get_recom_user($params));
    }



}
